package com.atguigu03.stream;

public class Employee implements Comparable{
    int id;
    String name;
    int age;
    double salary;
    public Employee() {
        System.out.println("EMP");
    }

    public Employee(int id) {
        this.id = id;
    }

    public Employee(int id, String name, int age, double salary) {
        this.id = id;
        this.name = name;
        this.age = age;
        this.salary = salary;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    @Override
    public String toString() {
        return "Employee{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", salary=" + salary +
                '}';
    }

    @Override
    public int compareTo(Object o) {
        if(this==o)
        return 0;
        if(o instanceof Employee){
            Employee e=(Employee) o;
            if(this.age>e.age){
                return 1;
            }else{
                return -1;
            }
        }
        return 0;
    }
}
